package com.example.datascreen.controller;

import com.example.datascreen.service.Impl.EssayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class EssayController {
    @Autowired
    EssayServiceImpl essayServiceImpl;

    @GetMapping({"/getData"})
    public List<List> getData() {
        return this.essayServiceImpl.getRjDaychart();
    }

    @GetMapping("/getEssayPie")
    public List getEssayPie(){
        Map<String,Integer> map = essayServiceImpl.getEssayPie();
        List pie = new ArrayList<>();
        for(String key : map.keySet()){
            Map temp = new HashMap<>();
            temp.put("value",map.get(key));
            temp.put("name",key);
            pie.add(temp);
        }
        return pie;
    }

    @GetMapping("/getLineMap")
    public Map getLineMap(){
        return essayServiceImpl.getLineMap();
    }

    @GetMapping("/getBarData")
    public List<List> getBarData(){
        return essayServiceImpl.getBarData();
    }

    @GetMapping("/getBookData")
    Map getTeamList(){
        return essayServiceImpl.getBooklist();
    }

    @RequestMapping("/getEssayList")
    public Map getEssayList(){
        return essayServiceImpl.getEssayData();
    }
}
